package com.zzedu.web.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.enums.OperatorType;
import com.zzedu.device.req.QueryAllZzPictureNode;
import com.zzedu.device.req.QueryDownDataReq;
import com.zzedu.device.req.QueryPictureByNodeContent;
import com.zzedu.device.rsp.ApiZzPictureBookNodeVO;
import com.zzedu.device.rsp.ApiZzPictureContentVO;
import com.zzedu.device.rsp.DownDataVO;
import com.zzedu.manager.IZzPictureBookManager;
import com.zzedu.result.Result;
import com.zzedu.utils.BaseReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 绘本
 */
@RestController
@RequestMapping("pictureBook")
public class PictureBookController {

    @Autowired
    IZzPictureBookManager pictureBookManager;
    /**
     * 绘本节点
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/queryAllNode"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "大屏-绘本-绘本节点", businessType = BusinessType.APP_DEVICE_TEACHER, operatorType = OperatorType.MOBILE)
    public Result<List<ApiZzPictureBookNodeVO>> queryAllNode(@Validated @RequestBody BaseReq<QueryAllZzPictureNode> req) {
        return pictureBookManager.queryAllNode(req.getData());
    }

    /**
     * 绘本-绘本节点-内容
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/queryPictureByNodeContent"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "大屏-绘本-绘本节点-内容", businessType = BusinessType.APP_DEVICE_TEACHER, operatorType = OperatorType.MOBILE)
    public Result<List<ApiZzPictureContentVO>> queryPictureByNodeContent(@Validated @RequestBody BaseReq<QueryPictureByNodeContent> req) {
        return pictureBookManager.queryPictureByNodeContent(req.getData());
    }

    /**
     * 大屏-绘本-下载内容列表
     * @param req
     * @return
     */
    @PostMapping(value = {"/queryDownData"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "大屏-绘本-下载内容列表", businessType = BusinessType.APP_DEVICE_TEACHER, operatorType = OperatorType.MOBILE)
    public Result<List<DownDataVO>> queryDownData(@Validated @RequestBody BaseReq<QueryDownDataReq> req) {
        return pictureBookManager.queryDownData(req.getData());
    }
}
